﻿// Owner: wangwj-f
// Co-Owner: 

#pragma once
#include "Vector2d.h"
#include "IUiViewMouseEventHandler.h"
#include "Vector3d.h"

namespace gcmp
{
    class Vector2d;
    class Vector3d;
    class IUiView;
    class IUiViewMouseEventArgs;
    class IGraphicsNodeReference;
}

namespace Sample
{
    enum class LookType
    {
        LookAround,
        CameraRotate,
    };

    class VisualUiViewMouseEventHandler : public gcmp::IUiViewMouseEventHandler
    {
    public:
        VisualUiViewMouseEventHandler()
            : m_rotateCenter(gcmp::Vector3d::Zero)
        {
            m_bMouseRightButtonDown = false;
            m_bMouseLeftButtonDown = false;
        }

        ~VisualUiViewMouseEventHandler() {}

        static VisualUiViewMouseEventHandler* Get()
        {
            static VisualUiViewMouseEventHandler uiAnimationUiDocEventHandler;
            return &uiAnimationUiDocEventHandler;
        }

        virtual void On(gcmp::IUiViewMouseEventArgs* pArgs) override;

    private:
        void CalculateRotateCenter(gcmp::Vector3d mousePt);
        void LookUtils(const gcmp::Vector3d & pt, LookType lookType);
    private:
        bool m_bMouseRightButtonDown;   // 鼠标右键按下
        bool m_bMouseLeftButtonDown;
        gcmp::Vector3d m_rotateCenter;
        gcmp::Vector2d m_ptBefore;      // 前一点（窗口坐标系）
    };
}
